from zhipuai import ZhipuAI
import numpy as np
client = ZhipuAI(api_key="98ffbf39fad9474f92e06713e9f5baa2.sJDYen6RlW70jU48") 

def textEmbedding(document):
    """
    文本编码
    """
    response = client.embeddings.create(
        model="embedding-2", #填写需要调用的模型编码
        input=document,
    )
    vectors = [record.embedding for record in response.data]
    return np.array(vectors, dtype=np.float32)

# print(response)